//
//  UIDevice+YCTools.m
//  Pods
//
//  Created by Apple on 2023/6/25.
//

#import "UIDevice+YCTools.h"

@implementation UIDevice (YCTools)

+ (CGFloat)yc_statusBarHeight {
    if (@available(iOS 13.0, *))
    {
        NSSet *set = [UIApplication sharedApplication].connectedScenes;
        UIWindowScene *windowScene = [set anyObject];
        UIStatusBarManager *statusBarManager = windowScene.statusBarManager;
        
        return statusBarManager.statusBarFrame.size.height;
    }
    else
    {
        return [UIApplication sharedApplication].statusBarFrame.size.height;
    }
}

+ (CGFloat)yc_safeTopHeight {
    if (@available(iOS 13.0, *))
    {
        NSSet *set = [UIApplication sharedApplication].connectedScenes;
        UIWindowScene *windowScene = [set anyObject];
        UIWindow *window = windowScene.windows.firstObject;
        
        return window.safeAreaInsets.top;
    }
    else if (@available(iOS 11.0, *))
    {
            UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
            return window.safeAreaInsets.top;
    }
    return 0;
}

+ (CGFloat)yc_safeBottomHeight {
    if (@available(iOS 13.0, *))
    {
        NSSet *set = [UIApplication sharedApplication].connectedScenes;
        UIWindowScene *windowScene = [set anyObject];
        UIWindow *window = windowScene.windows.firstObject;
        
        return window.safeAreaInsets.bottom;
    }
    else if (@available(iOS 11.0, *))
    {
            UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
            return window.safeAreaInsets.bottom;
    }
    return 0;
}

+ (CGFloat)yc_navigationBarHeight {
    return 44;
}

+ (CGFloat)yc_tabBarHeight {
    return 49;
}

+ (CGFloat)yc_navigationFullHeight {
    return [UIDevice yc_statusBarHeight] + [UIDevice yc_navigationBarHeight];
}

+ (CGFloat)yc_tabBarFullHeight {
    return [UIDevice yc_safeBottomHeight] + [UIDevice yc_tabBarHeight];
}

@end
